package projectEuler;

public class Problem_17 {
        public static void main(String[] args){
                long numberOfLetters = 0;
                int n;
                for(int count = 1; count <= 1000; count++){
                        n = count;
                        
                        if(n >= 100){ //To account for "hundred and"
                                numberOfLetters = numberOfLetters + 10;
                        }
                        if(n >= 400 && n < 500){
                                numberOfLetters = numberOfLetters + 4;
                        }else if(n >= 100||n <= 200||n >= 500||n >= 600||n >= 900){
                                numberOfLetters = numberOfLetters + 3;
                        }else if((n >= 300 && n < 400) || (n >= 700 && n < 900)){
                                numberOfLetters = numberOfLetters + 5;
                        }
                        if(n % 100 == 11 || n % 100 == 12){
                                numberOfLetters = numberOfLetters + 6;
                        }else if(n % 100 == 15 || n % 100 == 16){
                                numberOfLetters = numberOfLetters + 7;
                        }else if(n % 100 == 13||n % 100 == 14||n%100 == 19 ){
                                numberOfLetters = numberOfLetters + 8;
                        }else if(n % 100 == 17 || n % 100 == 18){
                                numberOfLetters = numberOfLetters + 9;
                        }else{
                                if(n%100 >= 90||(n%100 >=40&& n % 100 < 70)){
                                        numberOfLetters = numberOfLetters + 5;
                                }
                                if((n%100 >=20&& n % 100 < 40)||(n%100 >=80&& n % 100 < 90)){
                                        numberOfLetters = numberOfLetters + 6;
                                }
                                if(n%100 >= 70&& n % 100 < 80){
                                        numberOfLetters = numberOfLetters + 7;
                                }
                                //twenty 6 thirty 6 seventy 7 eighty 6
                                if(n % 10 == 1||n % 10 == 2||n % 10 == 5||n % 10 == 6||n % 10 == 9){
                                        numberOfLetters = numberOfLetters + 3;
                                }
                                if(n % 10 ==4){
                                        numberOfLetters = numberOfLetters + 4;
                                }
                                if(n % 10 == 3||n % 10 == 7||n % 10 == 8){
                                        numberOfLetters = numberOfLetters + 5;
                                }
                        }
                        
                        
                }
                System.out.println("Number of letters: "+numberOfLetters);
        }
}